#include <REGX52.H>
#include "Timer0.h"
#include "Key.h"
#include "INTRINS.H"

unsigned char KeyNum,LEDMoed;

void main()
{
	P2=0xFE;
	Timer0Init();
	while(1)
	{
		KeyNum=Key();
		if(KeyNum)
		{
			if(KeyNum)
			{
				LEDMoed++;
				if(LEDMoed>2) LEDMoed=0;
			}
		}
  }
}

void Timer0_Routine() interrupt 1
{
	static unsigned int t0;
	for(t0=0;t0<500;t0++)
	{
		TL0 = 0x18;		//设置定时初值
		TH0 = 0xFC;		//设置定时初值
		while(!TF0);
		TF0=0;
	}
	if(LEDMoed) P2=_crol_(P2,1);
	else P2=_cror_(P2,1);
}	